All Questions
Tagged with c++algorithms
71 questions
1vote
2answers
438views
Most efficient mapping of pixel to colors with colormaps
I'm working on a module that handles colormaps and I want to make the mapping of pixel to colors as efficient as possible. It is a performance critical section of our app. Our current solution works ...
0votes
3answers
849views
Mapping a range of values to a single value
So I have this problem where a specific ValuesA enum value is to be mapped to a respective ValuesB enum value, The trick is there can be multiple ValuesA mapping to a single ValuesB enum. So for the ...
1vote
2answers
484views
Efficient set method in run length encoded C++ map
I have been designing a C++ class that maps an integer to an integer using a vector. Because there is a lot of repetitive data (for example 11115555666222), I am using a compression scheme where I am ...
4votes
1answer
770views
Failure to understand logic behind dice roll permutation problem
I am having a lot of trouble understanding the logic behind the infamous "Find total ways to achieve given sum with n throws of dice having k faces" question. After extensively searching for ...
-3votes
1answer
586views
Is my algorithm for determining whether a ipv4 is public or private correct? [closed]
I have just created a function which checks whether a ipv4 is public or not. I have not heavily tested it yet since it is kind of practically impossible to do so (because I do not know where to start)....
0votes
1answer
543views
How to manually model a UML activity Diagram to JSON with Qt C++?
Suppose I have a kind of UML activity diagram with 1-n forks and joins. The assignment of the individual nodes relative to each other is defined by an XML relationship table via UUIDs where each ...
1vote
1answer
695views
Binary Search Tree with ID and Duplicate Values
I'm having trouble finding resources for this implementation I'm trying to figure out. I want to save nodes in a binary search tree (self balancing) containing an ID and value struct Score { int ...
7votes
2answers
1kviews
FIFO Min-Max-Heap for Rolling Median
I'm working on a system with hard real-time constraints in c++ and I need a very fast way to calculate the rolling/moving/streaming median of a set of numbers of size N=100 to 300. Normally this size ...
3votes
5answers
2kviews
Fastest way to find all numbers with digits
I have a huge set of over a million numbers of variable lengths. ['773', '2267', '8957251', '170597519', '373590109', '982451707', '999999937', ......] Now given a bunch of digits, say 3 and 7, I ...
3votes
4answers
119views
Store csv data as rows or columns in view of the needed processing?
Assume I have some data a csv-Files like ObjectName, PropertyA, PropertyB, PropertyC "Name1", 3, 1, 4 "Name2", 1, 5, 9 "Name3", 2, 6, 5 ... and a typical question I want to answer would be For ...
2votes
3answers
2kviews
Why did the C++ std library have a binary search tree well before a hashmap which is in many ways simpler
Looking at the two data structures and algorithms to handle them, a hashmap is not really any more complicated than a binary search tree and possibly less complicated. And the hashmap has the ...
3votes
1answer
1kviews
C++ generic graph search algorithm with generic data types
I'm trying to implement a generic graph search algorithm in C++, as part of assignment at university, and I encountered problems when trying to implement it, mostly struggling with templates. this is ...
-6votes
1answer
747views
What's the best algorithm to assign unique ID/serial numbers to a group of identical objects?
to make this question easier to visualize, let's call this the "chicken mesh problem". Suppose you have a rooster and a number (suppose it is 30) of baby chickens. Goal: Allow the rooster to ...
2votes
1answer
447views
Getting the number of bits set in a large integer
I have a large integer N < 10^2500. I need to get the number of bits set in its binary representation. The number is given in base 10 in a file. Here's how I'm doing it right now : I made a class ...
1vote
1answer
352views
How can I filter my coordinates system?
Following up with this, I have a bunch of coordinates and I draw them on a bitmap image as a coordinate system. Now, I would like to get rid of all the noise, and filter coordinates to give a "clearer"...